<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<script type="text/javascript">
    <!--
    var contextPath = '[[${#httpServletRequest.contextPath}]]';
    var roleId = '[[${roleId}]]';
    var setting = {
        check: {
            enable: true
        },
        callback: {
            onCheck: zTreeOnCheck
        }
    };
    $(document).ready(function () {
        $.post(contextPath + '/menuItem/roleTreeJson', {roleId: roleId},
            function (data, status) {
                $.fn.zTree.init($("#treeObj"), setting, data);
            }, "json");

    });

    function zTreeOnCheck(event, treeId, treeNode) {
        var treeObj = $.fn.zTree.getZTreeObj("treeObj");
        var nodes = treeObj.getCheckedNodes(true);
        var array = new Array();
        $.each(nodes, function (index, data) {
            array[index] = data.id;
        });
        $.post(contextPath + '/menuItem/treeCheckAction', {roleId: roleId, treeIds: array.join(",")},
            function (data, status) {

            }, "json");
    };
    //-->
</script>
<ul id="treeObj" class="ztree"></ul>
